package com.woniu.account.controller;


import com.woniu.account.model.TPoint;
import com.woniu.account.service.TPointService;
import com.woniu.core.util.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ly
 * @since 2024年03月01日
 */
@RestController
@RequestMapping("/tPoint")
public class TPointController {
    @Resource
    private TPointService tPointService;
    //积分登记表查询
    @GetMapping("/list")
    @ApiOperation("查询所有积分等级")
//    @RequiredRole(role = {"超级管理员","普通管理员","团队负责人"})
    public Result list() throws Exception {
       List<TPoint> search = tPointService.search();
        return Result.getListResult(TPoint.class).setMsg("查询成功").setData(search);
    }
    @GetMapping("/insert")
//    @RequiredRole(role = {"超级管理员","普通管理员","团队负责人"})
    @ApiOperation("新增积分等级")
    public Result insert(String pLevel,Double pMoney,Double pDiscount)throws Exception{
        TPoint tPoint=tPointService.insert(pLevel,pMoney,pDiscount);
        return Result.getResult(TPoint.class).setMsg("新增成功").setData(tPoint);
    }
    @GetMapping("/modify")
//    @RequiredRole(role = {"超级管理员","普通管理员","团队负责人"})
    @ApiOperation("修改积分等级金额和折扣率")
    public Result modify(Integer pointId,Double pMoney,Double pDiscount)throws Exception{
        TPoint tPoint=tPointService.modify(pointId,pMoney,pDiscount);
        return Result.getResult(TPoint.class).setMsg("修改成功").setData(tPoint);
    }


}

